#cmake file for test
#author:guyadong
#created:2018/05/10

set(_linke_libs faceapiclient common_source)
set(_test_targets)
add_executable(connect_test connect_test.cpp )
target_link_libraries(connect_test ${_linke_libs})
add_executable(multi_thread_test multi_thread_test.cpp ${DEPENDENT_SOURCE_DIR}/ThreadPool.cpp)

list(APPEND _test_targets connect_test)

add_executable(detect_face_test detect_face_test.cpp)
add_executable(compare_face_test compare_face_test.cpp)

set(_targets_with_ui detect_face_test compare_face_test multi_thread_test)
list(APPEND _test_targets ${_targets_with_ui})
foreach(_target ${_targets_with_ui})
	target_link_libraries(${_target} ${_linke_libs} gfaux_tools)
endforeach(_target)

if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) 
	# 复制测试图像到${PROJECT_BINARY_DIR}
	file(RELATIVE_PATH _current_folder ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_LIST_DIR})
	file(COPY ${CMAKE_CURRENT_LIST_DIR}/images DESTINATION ${PROJECT_BINARY_DIR}/${_current_folder})
	message(STATUS "copy ${CMAKE_CURRENT_LIST_DIR}/images to ${PROJECT_BINARY_DIR}/${_current_folder}")
	unset(_current_folder)
endif()
set_target_properties(${_test_targets} PROPERTIES FOLDER "test")
set_property(TARGET ${_test_targets} APPEND PROPERTY COMPILE_OPTIONS $<$<CXX_COMPILER_ID:MSVC>:/wd4275 /wd4251>)
################安装脚本#################
# 安装exe
install(TARGETS ${_test_targets} RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR} )
# 安装测试图像文件
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/images DESTINATION ${RUNTIME_INSTALL_DIR})
